﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using DataLib.Accounts.Bus;

namespace Ewts.Cumtomer
{
    public partial class CumAccountList : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                //归属地
                ListItem item = new ListItem();
                item.Text = "--请选择--";
                item.Value = "";
                DataLib.BLL.Sys_Library bllLib = new DataLib.BLL.Sys_Library();
  
                // 处理地
                dropGraphic.DataSource = bllLib.GetGraphicCity();
                dropGraphic.DataTextField = "libValue";
                dropGraphic.DataValueField = "libKey";
                dropGraphic.DataBind();
                dropGraphic.Items.Insert(0, item);
                bindData();
            }
        }
        protected void bindData()
        {
            User curUser = new User();
            curUser = (User)Session["UserInfo"];
            if (curUser != null)
            {
                hidUserLev.Value = curUser.UserType;
                if (curUser.UserType != "AD")
                {
                    dropGraphic.SelectedValue = curUser.CompanyCity;
                    dropGraphic.Enabled = false;

                }
            }

            string belong = dropGraphic.SelectedValue;
            if (belong == "全国")
            {
                belong = "";
            }

            DataLib.BLL.cum_aacounts cum = new DataLib.BLL.cum_aacounts();
            DataTable dt = cum.GetCumAccountList(belong);

            //DataSet ds = new DataSet();
            //DataLib.Accounts.Bus.User bUser = new DataLib.Accounts.Bus.User();
            
            /*
            string CompanyCity = null;
            //string TrueName = null;
            if (dropGraphic.SelectedValue != "全国")
            {
                CompanyCity = dropGraphic.SelectedValue;
            }
            //if (txtTrueName.Text.Trim() != "")
            //{
            //    TrueName = txtTrueName.Text.Trim();
            //}
             * */
            reptUser.DataSource = dt;
            reptUser.DataBind();
        }


        protected void dropBelong_SelectedIndexChanged(object sender, EventArgs e)
        {
            bindData();
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            bindData();
        }

        protected string GetStringLev(string levValue)
        {
            string text = "";
            DataLib.Model.Sys_Library libModel = new DataLib.Model.Sys_Library();
            DataLib.BLL.Sys_Library libBll = new DataLib.BLL.Sys_Library();
            DataTable dt = libBll.GetLibByCate("权限分级");
            foreach (DataRow dr in dt.Rows)
            {
                if (dr["libKey"].ToString() == levValue)
                {
                    text = dr["libValue"].ToString();
                    break;
                }
            }

            return text;
        }

        protected string GetLev(string levValue)
        {
            string text = "";
            return text;

        }
    }
}